package com.ipcb.ieee;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.net.URI;
import java.net.URISyntaxException;

import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class ieee extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        BufferedReader in = null;
        try {
            HttpClient client = new DefaultHttpClient();
            HttpGet request = new HttpGet();
            request.setURI(new URI("http://www.ieee.org/web/conferences/callforpapers/index.html?var1=cfp_filter_date&var2=31536000000&var3=&loc=0$3$1"));
            //request.setURI(new URI("http://www.nfclauncher.com"));
            HttpResponse response = client.execute(request);
            in = new BufferedReader
            (new InputStreamReader(response.getEntity().getContent()));
            StringBuffer sb = new StringBuffer("");
            String line = "";
            String NL = System.getProperty("line.separator");
            while ((line = in.readLine()) != null) {
                sb.append(line + NL);
            }
            
            in.close();
            String page = sb.toString();
            page = page.split(new String("<table width=\"585\" border=\"0\" cellpadding=\"5\" cellspacing=\"5\">"))[1];
            //'<table width="585" border="0" cellpadding="5" cellspacing="5">'
            page = page.split(new String("<td align=\"right\">"))[0];
            String[] tr  = page.split(new String("<tr>"));
            for(String t : tr ){
            	if(t.contains("<td>"))
            	{
            		
            		
            	}
            		
            }

            System.out.println(page);
            //Log.i("IEEE", page);
            } catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} finally {
            if (in != null) {
                try {
                    in.close();
                    } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}